import request from '@/utils/request'

/**
 * 详情
 * @param {*} id
 * @returns
 */
export function archiveDetail(id) {
  return request({
    url: `/api/v1/ctmCustomerChange/detail/infoCreate/${id}`,
    method: 'GET'
  })
}

/**
 * 保存或提交-经销商档案新建
 * @param {*} data
 * @returns
 */
export function archiveSaveOrSubmit(data) {
  return request({
    url: '/api/v1/ctmCustomerChange/createOrSubmit/infoCreate',
    method: 'POST',
    data
  })
}

/**
 * 终止
 * @param {*} id
 * @returns
 */
export function termination(id) {
  return request({
    url: `/api/v1/ctmCustomerChange/${id}`,
    method: 'POST'
  })
}
/**
 * 审核
 * @param {*} data
 * @returns
 */
export function auditInfoCreate(data) {
  return request({
    url: '/api/v1/ctmCustomerChange/review/infoCreate',
    method: 'POST',
    data
  })
}
/**
 * 根据客户编码获取门店
 * @param {*} customerCodes
 * @returns
 */
export function getShopByCustomerCode(customerCodes) {
  return request({
    url: `/api/v1/ctmCustomerShopBusiness/listChangeOfCooperationEndByCustomerCodes`,
    method: 'POST',
    data: {
      customerCodes
    }
  }).then(res => {
    res.data = (res.data || []).map(e => {
      e.shopBusinessId = e.id
      e.originalBusinessType = e.businessTypeName
      e.originalCode = e.code
      e.originalName = e.name
      e.originalOperateArea = e.operateArea
      e.originalShopAddr = e.shopAddr
      e.businessTypeName = ''
      e.code = ''
      e.name = ''
      // e.operateArea = ''
      // e.shopAddr = ''
      e.shopInfoPhone = ''
      e.shopServPhone = ''
      e.isNewBusinessTakeover = ''
      delete e.id
      return e
    })
    return res
  })
}
/**
 * 根据门店编码获取联系人
 * @param {*} shopCode
 * @returns
 */
export function getShopContactByShopCode(shopCode) {
  return request({
    url: `/api/v1/ctmCustomerContact/queryByShopCode/${shopCode}`,
    method: 'GET'
  })
}
